<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Edit Match</title>
    </h:head>
    <h:body>
        <ui:include src="../header.xhtml"/>
        <hr/>
        <h:panelGrid columns="4">
            <f:facet name="header">
                <h:outputText value="#{matchManagedBean.selectedMatch}"/>
            </f:facet>
            <f:view>
                <h:form>
                    <h:panelGrid columns="2">
                        <f:facet name="header">
                            <h:outputText value="Add/Edit Match"/>
                        </f:facet>
                        <h:outputLabel value="AwayTeamScore:" for="awayTeamScore" />
                        <h:inputText id="awayTeamScore" value="#{matchManagedBean.selectedMatch.awayTeamScore}" title="AwayTeamScore" />
                        <h:outputLabel value="HomeTeamScore:" for="homeTeamScore" />
                        <h:inputText id="homeTeamScore" value="#{matchManagedBean.selectedMatch.homeTeamScore}" title="HomeTeamScore" />
                        <h:outputLabel value="mDate:" for="mDate" />
                        <h:inputText id="Date" value="#{matchManagedBean.selectedMatch.mDate}" title="mDate" required="true" requiredMessage="The mDate field is required.">
                            <f:convertDateTime pattern="yyyy-MM-dd" />
                        </h:inputText>
                        <h:outputLabel value="mTime:" for="mTime" />
                        <h:inputText id="Time" value="#{matchManagedBean.selectedMatch.mTime}" title="mTime" required="true" requiredMessage="The mTime field is required."/>
                        <h:outputLabel value="Report:" for="report" />
                        <h:inputTextarea id="report" value="#{matchManagedBean.selectedMatch.report}" title="Report" />
                        &nbsp;
                        <h:column>
                            <h:commandButton value="Save" action="#{matchManagedBean.save}"/>
                            <h:commandButton value="Reset" type="reset"/>
                        </h:column>
                    </h:panelGrid>
                </h:form>
            </f:view>
            <h:panelGrid>
                <h:form>
                    <h:dataTable value="#{matchManagedBean.matchReferees}" var="item" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Referees"/>
                            </f:facet>
                            <h:outputText value="#{item}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Remove" action="#{matchManagedBean.removeReferee(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
                <h:form>
                    <h:dataTable value="#{matchManagedBean.otherReferees}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Other Referees"/>
                            </f:facet>
                            <h:outputText value="#{item}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Add" action="#{matchManagedBean.addReferee(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>

            </h:panelGrid>
            <h:panelGrid>
                <h:form>
                    <h:dataTable value="#{matchManagedBean.matchUmpires}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Umpires"/>
                            </f:facet>
                            <h:outputText value="#{item}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Remove" action="#{matchManagedBean.removeUmpire(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
                <h:form>
                    <h:dataTable value="#{matchManagedBean.otherUmpires}" var="item"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Other Umpires"/>
                            </f:facet>
                            <h:outputText value="#{item}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Add" action="#{matchManagedBean.addUmpire(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
            </h:panelGrid>
            <h:form>
                <h:panelGrid columns="1">
                    <f:facet name="header">
                        <h:outputText value="ASSIGN COURT"/>
                    </f:facet>
                    <h:dataTable value="#{matchManagedBean.courts}" var="item" rowClasses="jsfcrud_odd_row,jsfcrud_even_row">
                        <h:column>
                            <h:outputText value="#{item}"/>
                        </h:column>
                        <h:column>
                            <h:commandLink value="Assign" action="#{matchManagedBean.assignCourt(item)}"
                                           rendered="#{matchManagedBean.canAssignCourt(item)}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGrid>
            </h:form>
        </h:panelGrid>
    </h:body>
</html>

